-- my_sys_log --
delimiter $$

DROP TABLE IF EXISTS `my_sys_log`$$

CREATE TABLE `my_sys_log` (
  `my_log_id` int(11) NOT NULL AUTO_INCREMENT,
  `operator_id` char(32) NOT NULL,
  `operator_name` varchar(200) NOT NULL DEFAULT '',
  `operation` int(11) NOT NULL,
  `operand_id` char(32) NOT NULL,
  `operand_name` varchar(200) NOT NULL DEFAULT '',
  `datepoint` datetime NOT NULL,
  `remark` varchar(2000) DEFAULT '',
  PRIMARY KEY (`my_log_id`),
  UNIQUE KEY `my_log_id_UNIQUE` (`my_log_id`),
  KEY `IDX_OPERATOR_ID` (`operator_id`) USING HASH,
  KEY `IDX_OPERATION` (`operation`) USING HASH,
  KEY `IDX_OPERAND_ID` (`operand_id`) USING HASH,
  KEY `IDX_DATEPOINT` (`datepoint`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8$$

-- my_settings --
delimiter $$

DROP TABLE IF EXISTS `my_settings`$$

CREATE TABLE `my_settings` (
  `my_settings_id` int(11) NOT NULL AUTO_INCREMENT,
  `category` int(11) NOT NULL,
  `key` varchar(200) NOT NULL,
  `value` varchar(2000) NOT NULL DEFAULT '',
  PRIMARY KEY (`my_settings_id`),
  UNIQUE KEY `my_settings_category_key` (`category`,`key`) USING HASH
) ENGINE=InnoDB AUTO_INCREMENT=195 DEFAULT CHARSET=utf8$$

-- my_code --
delimiter $$

DROP TABLE IF EXISTS `my_code_path`$$
DROP TABLE IF EXISTS `my_code`$$

CREATE TABLE `my_code` (
  `category_id` int(11) NOT NULL,
  `value` varchar(200) NOT NULL,
  `text` varchar(2000) DEFAULT '',
  `parent` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`category_id`,`value`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8$$

delimiter $$

CREATE TABLE `my_code_path` (
  `a_value` varchar(200) NOT NULL COMMENT 'Value of ancestor.',
  `d_value` varchar(200) NOT NULL COMMENT 'Value of descendant',
  `category_id` int(11) NOT NULL,
  PRIMARY KEY (`category_id`,`a_value`,`d_value`),
  KEY `my_code_paths_d_value` (`category_id`,`d_value`),
  KEY `my_code_paths_a_value` (`category_id`,`a_value`),
  CONSTRAINT `my_code_paths_a_value` FOREIGN KEY (`category_id`, `a_value`) REFERENCES `my_code` (`category_id`, `value`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `my_code_paths_d_value` FOREIGN KEY (`category_id`, `d_value`) REFERENCES `my_code` (`category_id`, `value`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Trace of my_code'$$

-- my_runningnumbers --
delimiter $$

DROP TABLE IF EXISTS `my_runningnumber`$$

CREATE TABLE `my_runningnumber` (
  `num_type` int(11) DEFAULT NULL,
  `value` mediumtext
) ENGINE=InnoDB DEFAULT CHARSET=utf8$$

-- fs_file --
delimiter $$

DROP TABLE IF EXISTS `fs_file_content`$$
DROP TABLE IF EXISTS `fs_file_path`$$
DROP TABLE IF EXISTS `fs_file`$$

CREATE TABLE `fs_file` (
  `file_id` char(32) NOT NULL,
  `file_type` int(11) NOT NULL,
  `object_id` char(32) NOT NULL,
  `name` varchar(255) NOT NULL,
  `size` int(11) NOT NULL DEFAULT '0',
  `last_write_time` datetime NOT NULL,
  `description` varchar(200) NOT NULL DEFAULT '',
  `summary` varchar(2000) NOT NULL DEFAULT '',
  `attr` int(11) NOT NULL DEFAULT '0' COMMENT '0x01 - Read only\n0x02 - Hidden\n0x10 - Directory',
  `parent_id` varchar(45) DEFAULT NULL,
  `deleted` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`file_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8$$

delimiter $$

CREATE TABLE `fs_file_content` (
  `file_id` char(32) NOT NULL,
  `content` longblob,
  PRIMARY KEY (`file_id`),
  CONSTRAINT `fs_file_content_file_id` FOREIGN KEY (`file_id`) REFERENCES `fs_file` (`file_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8$$

delimiter $$

CREATE TABLE `fs_file_path` (
  `a_id` char(32) NOT NULL,
  `d_id` char(32) NOT NULL,
  PRIMARY KEY (`a_id`,`d_id`),
  KEY `fs_file_path_a_id_idx` (`a_id`),
  KEY `fs_file_path_d_id_idx` (`d_id`),
  CONSTRAINT `fs_file_path_d_id` FOREIGN KEY (`d_id`) REFERENCES `fs_file` (`file_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fs_file_path_a_id` FOREIGN KEY (`a_id`) REFERENCES `fs_file` (`file_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8$$
